package net.tv90.bfmccore.slot;

import java.util.HashMap;

public class MainWeapon {

    public String MainWeapon = "AIR";
    public String MainWeaponAmmo = "AIR";
    public int MainWeaponAmmoCount = 0;
    public HashMap<String, String> MainWeaponAttachment = null;

    public MainWeapon(String MainWeapon, String MainWeaponAmmo, int MainWeaponAmmoCount, HashMap<String, String> MainWeaponAttachment) {
        this.MainWeapon = MainWeapon;
        this.MainWeaponAmmo = MainWeaponAmmo;
        this.MainWeaponAmmoCount = MainWeaponAmmoCount;
        this.MainWeaponAttachment = MainWeaponAttachment;
    }

    public MainWeapon(HashMap<Object, Object> map) {
        this.MainWeapon = (String) map.get("MainWeapon");
        this.MainWeaponAmmo = (String) map.get("MainWeaponAmmo");
        this.MainWeaponAmmoCount = (int) map.get("MainWeaponAmmoCount");
        this.MainWeaponAttachment = (HashMap<String, String>) map.get("MainWeaponAttachment");
    }

    public MainWeapon() {
    }

    //成员变量的getter和setter方法
    public void setMainWeapon(String MainWeapon, String MainWeaponAmmo, int MainWeaponAmmoCount) {
        this.MainWeapon = MainWeapon;
        this.MainWeaponAmmo = MainWeaponAmmo;
        this.MainWeaponAmmoCount = MainWeaponAmmoCount;
        this.MainWeaponAttachment = null;
    }

    public String getMainWeapon() {
        return this.MainWeapon;
    }

    public String getMainWeaponAmmo() {
        return this.MainWeaponAmmo;
    }

    public int getMainWeaponAmmoCount() {
        return this.MainWeaponAmmoCount;
    }

    public void setMainWeaponAttachment(String type, String att) {
        MainWeaponAttachment.put(type, att);
    }

    public String getMainWeaponAttachment(String type) {
        return MainWeaponAttachment.getOrDefault(type, "AIR");
    }

    //序列化
    //MainWeapon{MainWeapon:'',MainWeaponAmmo:'',MainWeaponAmmoCount:'',MainWeaponAttachment:''}
    @Override
    public String toString() {
        return "MainWeapon{MainWeapon:'" + this.MainWeapon + "',MainWeaponAmmo:'" + this.MainWeaponAmmo +
                "',MainWeaponAmmoCount:'" + this.MainWeaponAmmoCount + "',MainWeaponAttachment:'" + this.MainWeaponAttachment + "'}";
    }

    public HashMap<Object, Object> toHashMap() {
        HashMap<Object, Object> map = new HashMap<>();
        map.put("MainWeapon", this.MainWeapon);
        map.put("MainWeaponAmmo", this.MainWeaponAmmo);
        map.put("MainWeaponAmmoCount", this.MainWeaponAmmoCount);
        map.put("MainWeaponAttachment", this.MainWeaponAttachment);
        return map;
    }

    public void setAmmo(String ammo, int amount) {
        this.MainWeaponAmmo = ammo;
        this.MainWeaponAmmoCount = amount;
    }

    public void setAmmoType(String ammoType) {
        this.MainWeaponAmmo = ammoType;
    }
}
